<?php
/*
 * Copyright 2009 Eat Local Food, LLC
 * Copyright (c) 2007 osCommerce(functions were originally part
 * of osCommerce, extracted, renamed and modified for use in gwtCommerce).
 *
 * This file is part of gwtCommerce.
 *
 * gwtCommerce is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 2 of the License, or
 * (at your option) any later version.
 *
 * gwtCommerce is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with gwtCommerce.  If not, see <http://www.gnu.org/licenses/>.
 */



function remove_module($module) {
	$module_key = addcslashes($module,'%_');
	$sql = 'delete from ' . TABLE_CONFIGURATION . ' where configuration_key like '.  "'" . $module_key . "\_%'";
	mysql_query($sql) or die(mysql_error());
}

function run_sql($sql) {
	mysql_query($sql) or die(mysql_error());
}

function check_module($module) {
	$sql = 'select configuration_value from ' . TABLE_CONFIGURATION . ' where configuration_key = \'' . $module . '_STATUS\'';
	$dataReturned = mysql_query($sql) or die(mysql_error());
	return mysql_num_rows($dataReturned);
}

function check_zone($geo_zone_id,$country_id, $country_zone_id) {
	$check_flag = true;
	if ((int)$geo_zone_id > 0)
	{
		$check_flag = false;
		$sqlQuery = "select zone_id from " . TABLE_ZONES_TO_GEO_ZONES . " where geo_zone_id = '" . $geo_zone_id . "' and zone_country_id = '" . $country_id . "' order by zone_id";
		$dataReturned = mysql_query($sqlQuery) or die(mysql_error());
		while($row = mysql_fetch_array($dataReturned))
		{
			$zone_id = $row['zone_id'];
			if ($zone_id < 1)
			{
            			$check_flag = true;
            			break;
          		} 
			elseif ($zone_id == $country_zone_id) 
			{
            			$check_flag = true;
            			break;
          		}
        	}
        }
	return $check_flag;
}
?>
